#include "Environment.h"

namespace BlobSalladDS
{
	Environment::Environment(double x, double y, double w, double h)
	{
		this->left = x;
		this->right = x + w;
		this->top = y;
		this->bottom = y + h;
	}

	bool Environment::collision(Vector &curPos, Vector &prevPos)
	{
		bool collide = false;

		if (curPos.getX() < this->left)
		{
			curPos.setX(this->left);
			collide = true;
		}
		else if (curPos.getX() > this->right)
		{
			curPos.setX(this->right);
			collide = true;
		}
		if (curPos.getY() < this->top)
		{
			curPos.setY(this->top);
			collide = true;
		}
		else if (curPos.getY() > this->bottom)
		{
			curPos.setY(this->bottom);
			collide = true;
		}

		return collide;
	}
}
